<?php
include_once $_SERVER['DOCUMENT_ROOT'].'/phorm/model/fields/UnixTimestamp.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/phorm/database/core/IAutoUpdateColumn.php';

class LastModifiedTimestamp extends UnixTimestamp implements IAutoUpdateColumn
{	
	public function __construct(IDatabaseRecord &$object, $defaultValue = 'now')
	{
		// previoulsy was using debug_backtrace()
		// but we found an issue when (we think) php was running as CGI.  The ['object']
		// key was not being passed.
		// signature was:
		// public function __construct($length = null, $defaultValue = null)
		// $this->model was being set via:
		// $tmp =  debug_backtrace();
		// $this->model        = &$tmp[1]['object'];
		
		$this->model         = $object;
		$this->field_type    = 'integer';
		$this->length        = 11;
		$this->defaultValue  = $defaultValue; 
	}
	
	public function update()
	{
		$this->value = time();
	}
		
}
?>
